package com.soft.cart;

import com.soft.dao.TCartDao;
import com.soft.entity.TCart;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;
import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
public class testCartDao {
    @Autowired
    TCartDao tCartDao;
    @Test
    public void testQueryAll(){
        System.out.println(tCartDao.queryAll(new TCart()));
    }
    @Test
    public void testUpdata(){
//        TCart tCart = new TCart();
//        tCart.setCount();
//        tCartDao.update()
    }
    @Test
    public void testInsert(){
        Date date = new Date(System.currentTimeMillis());
        TCart tCart = new TCart(null, 5, 2, 1,date, date, null);
        tCartDao.insert(tCart);
    }
    @Test
    public void testSelectAllProducts(){
        System.out.println(tCartDao.selectAllProduct(4));
    }

    @Test
    public void testgetCartAndProduct(){
        System.out.println(tCartDao.getCartAndProduct(4));
    }

    @Test
    public void testqueryAll(){
        //不存在检测
        TCart tCart = new TCart();
        tCart.setUserId(4);
        tCart.setProductId(10);
        System.out.println("1=="+tCartDao.queryAll(tCart));
        //存在检测
        tCart.setUserId(4);
        tCart.setProductId(3);
        System.out.println("2+=="+tCartDao.queryAll(tCart));
        //多条数据检测
        tCart.setUserId(4);
        tCart.setProductId(null);
        System.out.println("3+=="+tCartDao.queryAll(tCart));
    }
}
